home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
batchut
/
mfwrite.zip
/
WRITE.DOC
< prev
Wrap
Text File
|
1990-10-25
|
5KB
|
125 lines
Write sends a string to standard output (much like the `echo' command), with
a few extras.
When called without parameters, it displays the following help message:
write.com version 1.1, Markus G. Fischer, Oct. 1990
usage: write <string>
Outputs <string> to standard output, without a CR-LF sequence.
Meta-strings in the form $c are expanded much like in the `prompt'
(the differences are marked with a `*', unknown codes are skipped).
$ the `$' character g the `>' character
* t time up to the seconds l the `<' character
* d date without day of the week b the `|' character
p current logical directory q the `=' character
* r current physical directory h the backspace character
n default drive letter e the escape character
* v volume label * f the form-feed character
* ^c CTRL-c (if '@' <= c <= '_') _ the CR LF sequence
Bug: `$^J' sends the CR-LF sequence, not just the LF.
The program is released under the `free-source-ware' concept. No fee,
unrestricted distribution of unmodified executable and source.
Bugs, comments, updates, etc. should be send to "fisher@sc2a.unige.ch".
I think there is not much to add, exept maybe a few examples... (Since I wrote
this program, I found many different applications for it.)
Possible uses:
- Date-and-time stamps to log files
- Printer control (write $eE>LPT1)
- Automatic program execution (write <keys>|program, the sequence `$^@;' would
even simulate the <F1> key !)
- Aliases involving the display of the current directory, the volume label,
the time or the date
- Batch-file ``tricks'' to push and pop the directory, for example
The original idea was to replace DOS's `echo', because I didn't want the CR-LF
sequence added at the end. At that time I had to download several soft fonts
on a LaserJet, which didn't contain a logical font-number. The batch file
looked somthing like this :
@echo off
echo Helvetica: orientation portrait, taille 10 points, mode normal.
echo ^[*c58D^[*c5F > LPT1
copy \HPFONTS\Helv10n.HP/b LPT1:/b > NUL
echo ^[*c58D^[*c5F > LPT1
[...]
It worked fine, but each echo ...>LPT1 caused a CR-LF sequence to be sent
to the printer... resulting in one or two empty sheets of paper.
Also, I never like control characters in a batch file, they aren't always
displayed the same way. What's more, I couldn't send a `echo ^[E>LPT1'
(printer reset), as the <Esc> killed my command line. Thus the write program,
largely inspired by the `prompt' syntax. (i.e. `$e' -> <Esc>...)
The batch was changed to something like this:
@echo off
echo Helvetica: orientation portrait, taille 10 points, mode normal.
write $e*c58D$e*c5F > LPT1
copy \HPFONTS\Helv10n.HP/b LPT1:/b > NUL
write $e*c58D$e*c5F > LPT1
[...]
write $eE
A few days later, I changed my `eject.bat' to a simple alias: `write ^L>LPT1',
my `t.bat' (display time and date) to another alias: `write $t $d', and so
forth. Another file processing batch file got a new line `write .' (display
dots _on_the_same_line_ as you process), and of course, `write $e[1m', or
other ansi sequences became simpler and could be isolated on separate lines.
The same `write' could be used to add time & date stamps to a log file,
display the `cwd' from a batch file, etc.
The next application I found involves the `push' and `pop' or directories,
as I profoundly dislike having too many resident programs active at the
same time. Here an example (assuming %tmp% points to your tmp diectory, i.e.
a ram-drive) :
@echo off
write @echo off$_$n:$_cd $p$_del %tmp%popdir.bat > %tmp%popdir.bat
X:
cd \needed.dir
rem *** processing ***
call %tmp%popdir
rem *** closing message ***
The %tmp%popdir.bat contains something like:
@echo off
C:
cd C:\CURRENT\SUBDIR
del D:\popdir.bat
In other words, you can easily write a batch from within a batch, and
`call' it when needed... If you use a ram-drive, it is quite fast, too.
Another example is `toc.bat' that I use to switch from the directory of
a subst'ituted drive to the same directory (the real one) on drive C::
@ write @C:$_@cd $r$_@del %TMP%~toc~.bat>%TMP%~toc~.bat
@ %TMP%~toc~.bat
(figure it out for yourself)
Finally, I added the options `$f' (form feed) and `$^?' (control characters)
to completely banish the typing of control characters from the command line
and to allow full control of programs reading standard input.
Well, that's enough examples, you will certainly find your own applications.
write Logical Dir : $p$_Physical Dir : $r$_Volume Name : $v$_
Markus Fischer
University of Geneva
Department of Anthropology
12, rue Gustave Revilliod
1227 CAROUGE (Geneve)
Switzerland
<fisher@sc2a.unige.ch>
<fisher@cgeuge52.bitnet>